# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/12 22:24
# @Author   : Robot-Zsj
"""
description:

i:
5
5000 2000 5000 8000 1800
o:
"""


class TreeNode:
    def __init__(self, val):
        self.val = val
        self.height = None
        self.left = None
        self.mid = None
        self.right = None


class Tree:
    def __init__(self):
        self.root = None
        self.height = 0

    def add(self, val):
        node = TreeNode(val)

        if self.root is None:
            node.height = 1
            self.root = node
            self.height = 1
        else:
            cur = self.root

            while True:
                node.height = cur.height + 1
                self.height = max(node.height, self.height)

                if val < cur.val - 500:
                    if cur.left is None:
                        cur.left = node

                        break
                    else:
                        cur = cur.left
                elif val > cur.val + 500:
                    if cur.right is None:
                        cur.right = node
                        break
                    else:
                        cur = cur.right
                else:
                    if cur.mid is None:
                        cur.mid = node
                        break
                    else:
                        cur = cur.mid


while True:
    try:
        n = int(input())
        nums = list(map(int, input().split()))

        tree = Tree()
        for num in nums:
            tree.add(num)
        print(tree.height)
    except:
        break

